package com.tx.core.tree.model;

import java.io.Serializable;
import java.util.List;

/**
 * <树代理，子节点集合无序，节点不可重复>
 * <功能详细描述>
 *
 * @author PengQingyang
 * @version [版本号, 2012-10-5]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
public class TreeEntityProxy<ID extends Serializable, T>
        implements TreeEntity<ID, TreeEntityProxy<ID, T>> {

    private T target;

    private ID id;

    private ID parentId;

    private List<TreeEntityProxy<ID, T>> children;

    public TreeEntityProxy(TreeEntityAdapter<ID, T> adapter, T target) {
        this.id = adapter.getId(target);
        this.parentId = adapter.getParentId(target);
        this.target = target;
    }

    public T getTarget() {
        return target;
    }

    public void setTarget(T target) {
        this.target = target;
    }

    public void setId(ID id) {
        this.id = id;
    }

    public void setParentId(ID parentId) {
        this.parentId = parentId;
    }

    @Override
    public ID getId() {
        return id;
    }

    @Override
    public ID getParentId() {
        return parentId;
    }

    @Override
    public List<TreeEntityProxy<ID, T>> getChildren() {
        return this.children;
    }

    @Override
    public void setChildren(List<TreeEntityProxy<ID, T>> children) {
        this.children = children;
    }
}
